import { ajaxPost } from 'api/axios'

export const uploadData = (url, file, fileName) => {
  let data = new FormData()

  if (Array.isArray(file)) {
    file.map((item, index) => {
      const reader = new FileReader()
      reader.readAsDataURL(item)
      data.append(index, item)
    })
  } else {
    data.append('files', file)
  }

  return ajaxPost(url, data)
}
